//
//  DBHandler.h
//  ui_day20_DataBase
//
//  Created by ChenNing on 15/9/11.
//  Copyright (c) 2015年 陈宁. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <sqlite3.h>
#import "CollectModel.h"
#import "CollectedModel.h"
#import "SearchHistoryModel.h"

@interface DBHandler : NSObject
{
    // 数据库指针,直接操作本地的数据库文件
    sqlite3 *_dbPoint;
}


//单例方法
+(DBHandler *)shareInstance;

// 打开数据库
- (BOOL)openDB;

// 关闭数据库
- (BOOL)closeDB;

// 创建表
- (BOOL) createTable1;
- (BOOL) createTable2;
- (BOOL) createTableSearch;
// 插入对象
- (BOOL) insertVideo:(CollectModel *)video;
- (BOOL) insertCollect:(CollectedModel *)collect;
- (BOOL) insertSearch:(SearchHistoryModel *)search;
//// 更新对象
- (BOOL) updateCollect:(CollectModel *)collect whereTitle:(NSString *)title;
- (BOOL) updateCollected:(CollectedModel *)collect wheretitle:(NSString *)title;
// 删除对象
- (BOOL) deleteVideo:(CollectModel *)video;
- (BOOL) deletecollect:(CollectedModel *)collect;
- (BOOL) deleteSearch:(NSArray *)searchArr;
// 查询所有
- (NSArray *)selectAllCollect;
- (NSArray *)selectAllCollected;
- (NSArray *)selectAllSearch;
// 查询 根据视频地址
- (CollectModel *)selectVideoByVideoStr:(NSString *)videoStr;

@end
